; (function () {
  this.projectConfigTab = new Vue({
    el: '#projectConfigIndex',
    data: {
      menuList: [
        {name: '项目信息', url: ''},
        {name: '楼宇楼层配置', url: ''},
        {name: '单元配置', url: ''},
        {name: '平面图配置', url: ''},
        {name: '费项配置', url: ''},
        {name: '相关文件', url: ''}
      ],
      active: sessionStorage.getItem('projectPage') || '项目信息',
			projectName: sessionStorage.getItem('projectName') || '--'
    },
		methods: {
			menuShow () {
				if (this.active == '项目信息') {
					$('.projectConfig-wrap').load('modules/projectConfig/page/projectInfo.html')
				}
				if (this.active == '楼宇楼层配置') {
					$('.projectConfig-wrap').load('modules/projectConfig/page/building.html')
				}

				if (this.active == '单元配置') {
					hlhttp.put({
						url: 'check_unit_config',
						data: {project_id: hlUrlUtil.GetQueryString('projectId')},
						success: () => {
							$('.projectConfig-wrap').load('modules/projectConfig/page/unit.html')
						},
						error: () => {
							this.active = '楼宇楼层配置';
							sessionStorage.setItem('projectPage', this.active)
							hl.toast('请配置楼宇楼层')
							$('.projectConfig-wrap').load('modules/projectConfig/page/unit.html')
						}
					})
				}

				if (this.active == '平面图配置') {
					$('.projectConfig-wrap').load('modules/projectConfig/page/planGraph.html')
				}

				if (this.active == '费项配置') {
					hlhttp.put({
						url: 'check_project_config',
						data: {project_id: hlUrlUtil.GetQueryString('projectId')},
						success: () => {
							$('.projectConfig-wrap').load('modules/projectConfig/page/expenditure.html')
						},
						error: () => {
							this.active = '项目信息';
							sessionStorage.setItem('projectPage', this.active)
							hl.toast('请配置单元')
							$('.projectConfig-wrap').load('modules/projectConfig/page/projectInfo.html')
						}
					})
				}
        
				if (this.active == '相关文件') {
					$('.projectConfig-wrap').load('modules/projectConfig/page/file.html')
				}
			},
			tab (data) {
				if (!hlUrlUtil.GetQueryString('projectId')) {
					if (data.name == "楼宇楼层配置") {
						hl.toast('请完善项目信息')
					}
					if (data.name == "单元配置") {
						hl.toast('请先至少新建一栋楼宇')
					}
					if (data.name == "平面图配置") {
						hl.toast('项目没有配置完成')
					}
					if (data.name == "费项配置") {
						hl.toast('请先完善其它信息')
					}
					if (data.name == "相关文件") {
						hl.toast('请完善项目信息')
					}
					return
				};
				this.active = data.name;
				sessionStorage.setItem('projectPage', this.active)
				this.menuShow()
			}
		},
		mounted () {
			if (!hlUrlUtil.GetQueryString('projectId')) {
				sessionStorage.clear();
				this.active = '项目信息';
				this.projectName = '--';
			}
			this.menuShow()
			window.onpopstate = function () {
				window.onpopstate = null;
				sessionStorage.clear();
			}
		}
  })
}())
